/**
 *
 * Created by ThinkPad on 2021-04-26.
 */
module.exports = class HttpError {
    constructor() {
    // --- 1xx Informational ---
    this._SC_CONTINUE=[100, "Continue"]
    this._SC_SWITCHING_PROTOCOLS=[101, "Switching Protocols"]
    this._SC_PROCESSING=[102, "Processing"]

    // --- 2xx Success ---
    this._SC_OK=[200, "OK"]
    this._SC_CREATED=[201, "Created"]
    this._SC_ACCEPTED=[202, "Accepted"]
    this._SC_NON_AUTHORITATIVE_INFORMATION=[203, "Non-Authoritative Information"]
    this._SC_NO_CONTENT=[204, "No Content"]
    this._SC_RESET_CONTENT=[205, "Reset Content"]
    this._SC_PARTIAL_CONTENT=[206, "Partial Content"]
    this._SC_MULTI_STATUS=[207, "Multi-Status"]

    // --- 3xx Redirection ---
    this._SC_MULTIPLE_CHOICES=[300, "Multiple Choices"]
    this._SC_MOVED_PERMANENTLY=[301, "Moved Permanently"]
    this._SC_MOVED_TEMPORARILY=[302, "Move temporarily"]
    this._SC_SEE_OTHER=[303, "See Other"]
    this._SC_NOT_MODIFIED=[304, "Not Modified"]
    this._SC_USE_PROXY=[305, "Use Proxy"]
    this._SC_TEMPORARY_REDIRECT=[307, "Temporary Redirect"]

    // --- 4xx Client Error ---
    this._SC_BAD_REQUEST=[400, "Bad Request"]
    this._SC_UNAUTHORIZED=[401, "Unauthorized"]
    this._SC_PAYMENT_REQUIRED=[402, "Payment Required"]
    this._SC_FORBIDDEN=[403, "Forbidden"]
    this._SC_NOT_FOUND=[404, "Not Found"]
    this._SC_METHOD_NOT_ALLOWED=[405, "Method Not Allowed"]
    this._SC_NOT_ACCEPTABLE=[406, "Not Acceptable"]
    this._SC_PROXY_AUTHENTICATION_REQUIRED=[407, "Proxy Authentication Required"]
    this._SC_REQUEST_TIMEOUT=[408, "Request Timeout"]
    this._SC_CONFLICT=[409, "Conflict"]
    this._SC_GONE=[410, "Gone"]
    this._SC_LENGTH_REQUIRED=[411, "Length Required"]
    this._SC_PRECONDITION_FAILED=[412, "Precondition Failed"]
    this._SC_REQUEST_TOO_LONG=[413, "Request Entity Too Large"]
    this._SC_REQUEST_URI_TOO_LONG=[414, "Request-URI Too Long"]
    this._SC_UNSUPPORTED_MEDIA_TYPE=[415, "Unsupported Media Type"]
    this._SC_REQUESTED_RANGE_NOT_SATISFIABLE=[416, "Requested Range Not Satisfiable"]
    this._SC_EXPECTATION_FAILED=[417, "Expectation Failed"]
    this._SC_INSUFFICIENT_SPACE_ON_RESOURCE=[419, "Insufficient Space on Resource"]
    this._SC_METHOD_FAILURE=[420, "Method Failure"]
    this._SC_UNPROCESSABLE_ENTITY=[422, "Unprocessable Entity"]
    this._SC_LOCKED=[423, "Locked"]
    this._SC_FAILED_DEPENDENCY=[424, "Failed Dependency"]

    // --- 5xx Server Error ---
    this._SC_INTERNAL_SERVER_ERROR=[500, "Server Error"]
    this._SC_NOT_IMPLEMENTED=[501, "Not Implemented"]
    this._SC_BAD_GATEWAY=[502, "Bad Gateway"]
    this._SC_SERVICE_UNAVAILABLE=[503, "Service Unavailable"]
    this._SC_GATEWAY_TIMEOUT=[504, "Gateway Timeout"]
    this._SC_HTTP_VERSION_NOT_SUPPORTED=[505, "HTTP Version Not Supported"]
    this._SC_INSUFFICIENT_STORAGE=[507, "Insufficient Storage"]
    }
    getError (code){
        const returnKey = Object.getOwnPropertyNames(this).filter(key=>{
            return this[key][0] == code
        })
        if(returnKey.length>0) return this[returnKey[0]]
        return returnKey
    }

    get SC_CONTINUE() {
        return this._SC_CONTINUE;
    }

    get SC_SWITCHING_PROTOCOLS() {
        return this._SC_SWITCHING_PROTOCOLS;
    }

    get SC_PROCESSING() {
        return this._SC_PROCESSING;
    }

    get SC_OK() {
        return this._SC_OK;
    }

    get SC_CREATED() {
        return this._SC_CREATED;
    }

    get SC_ACCEPTED() {
        return this._SC_ACCEPTED;
    }

    get SC_NON_AUTHORITATIVE_INFORMATION() {
        return this._SC_NON_AUTHORITATIVE_INFORMATION;
    }

    get SC_NO_CONTENT() {
        return this._SC_NO_CONTENT;
    }

    get SC_RESET_CONTENT() {
        return this._SC_RESET_CONTENT;
    }

    get SC_PARTIAL_CONTENT() {
        return this._SC_PARTIAL_CONTENT;
    }

    get SC_MULTI_STATUS() {
        return this._SC_MULTI_STATUS;
    }

    get SC_MULTIPLE_CHOICES() {
        return this._SC_MULTIPLE_CHOICES;
    }

    get SC_MOVED_PERMANENTLY() {
        return this._SC_MOVED_PERMANENTLY;
    }

    get SC_MOVED_TEMPORARILY() {
        return this._SC_MOVED_TEMPORARILY;
    }

    get SC_SEE_OTHER() {
        return this._SC_SEE_OTHER;
    }

    get SC_NOT_MODIFIED() {
        return this._SC_NOT_MODIFIED;
    }

    get SC_USE_PROXY() {
        return this._SC_USE_PROXY;
    }

    get SC_TEMPORARY_REDIRECT() {
        return this._SC_TEMPORARY_REDIRECT;
    }

    get SC_BAD_REQUEST() {
        return this._SC_BAD_REQUEST;
    }

    get SC_UNAUTHORIZED() {
        return this._SC_UNAUTHORIZED;
    }

    get SC_PAYMENT_REQUIRED() {
        return this._SC_PAYMENT_REQUIRED;
    }

    get SC_FORBIDDEN() {
        return this._SC_FORBIDDEN;
    }

    get SC_NOT_FOUND() {
        return this._SC_NOT_FOUND;
    }

    get SC_METHOD_NOT_ALLOWED() {
        return this._SC_METHOD_NOT_ALLOWED;
    }

    get SC_NOT_ACCEPTABLE() {
        return this._SC_NOT_ACCEPTABLE;
    }

    get SC_PROXY_AUTHENTICATION_REQUIRED() {
        return this._SC_PROXY_AUTHENTICATION_REQUIRED;
    }

    get SC_REQUEST_TIMEOUT() {
        return this._SC_REQUEST_TIMEOUT;
    }

    get SC_CONFLICT() {
        return this._SC_CONFLICT;
    }

    get SC_GONE() {
        return this._SC_GONE;
    }

    get SC_LENGTH_REQUIRED() {
        return this._SC_LENGTH_REQUIRED;
    }

    get SC_PRECONDITION_FAILED() {
        return this._SC_PRECONDITION_FAILED;
    }

    get SC_REQUEST_TOO_LONG() {
        return this._SC_REQUEST_TOO_LONG;
    }

    get SC_REQUEST_URI_TOO_LONG() {
        return this._SC_REQUEST_URI_TOO_LONG;
    }

    get SC_UNSUPPORTED_MEDIA_TYPE() {
        return this._SC_UNSUPPORTED_MEDIA_TYPE;
    }

    get SC_REQUESTED_RANGE_NOT_SATISFIABLE() {
        return this._SC_REQUESTED_RANGE_NOT_SATISFIABLE;
    }

    get SC_EXPECTATION_FAILED() {
        return this._SC_EXPECTATION_FAILED;
    }

    get SC_INSUFFICIENT_SPACE_ON_RESOURCE() {
        return this._SC_INSUFFICIENT_SPACE_ON_RESOURCE;
    }

    get SC_METHOD_FAILURE() {
        return this._SC_METHOD_FAILURE;
    }

    get SC_UNPROCESSABLE_ENTITY() {
        return this._SC_UNPROCESSABLE_ENTITY;
    }

    get SC_LOCKED() {
        return this._SC_LOCKED;
    }

    get SC_FAILED_DEPENDENCY() {
        return this._SC_FAILED_DEPENDENCY;
    }

    get SC_INTERNAL_SERVER_ERROR() {
        return this._SC_INTERNAL_SERVER_ERROR;
    }

    get SC_NOT_IMPLEMENTED() {
        return this._SC_NOT_IMPLEMENTED;
    }

    get SC_BAD_GATEWAY() {
        return this._SC_BAD_GATEWAY;
    }

    get SC_SERVICE_UNAVAILABLE() {
        return this._SC_SERVICE_UNAVAILABLE;
    }

    get SC_GATEWAY_TIMEOUT() {
        return this._SC_GATEWAY_TIMEOUT;
    }

    get SC_HTTP_VERSION_NOT_SUPPORTED() {
        return this._SC_HTTP_VERSION_NOT_SUPPORTED;
    }

    get SC_INSUFFICIENT_STORAGE() {
        return this._SC_INSUFFICIENT_STORAGE;
    }
}